package cn.guo.dao.impl;


import java.util.List;

import cn.guo.dao.IFilmDao;
import cn.guo.entity.Film;

/**
 * 影片类的实现类
 *
 */
public class FilmDao extends BaseDao<Film> implements IFilmDao {

	@SuppressWarnings("unchecked")
	public List<Film> getAll(String fname) {
		return getSessionFactory().getCurrentSession()//
			.createQuery("from Film where fname like ?")//
			.setParameter(0, "%" +fname + "%")//
			.list();
	}
	
	public Film findById(int id) {
		String hql = "from Film e left join fetch e.filmType where e.id=?";			
		return (Film) getSessionFactory()
			.getCurrentSession()
			.createQuery(hql)
			.setParameter(0, id)
			.uniqueResult();
	}

}

